﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using LM.Negocio.Objetos;

namespace LM.Repositorios.Maps
{
    class TelefoneMap : EntityTypeConfiguration<Telefone>
    {
        public TelefoneMap()
        {
            this.HasKey(t => t.Codigo);          

            // Table & Column Mappings
            this.ToTable("Telefone");
            this.Property(t => t.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).HasColumnName("Id"); 
            this.Property(t => t.Codigo).HasColumnName("Codigo");
            this.Property(t => t.Ddd).HasColumnName("Ddd");
            this.Property(t => t.Numero).HasColumnName("Numero");
            this.Property(t => t.Tipo).HasColumnName("Tipo");
            this.Property(t => t.ClienteId).HasColumnName("ClienteId");
            this.Property(t => t.GaragemId).HasColumnName("GaragemId");

            // Relationships
            this.HasRequired(t => t.Cliente)
                .WithMany(t => t.Telefones)
                .HasForeignKey(d => d.ClienteId);
        }
    }
}
